home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / net / tf02.lha / TinyFugue / tf-lib / kbfunc.tf < prev    next >
Text File  |  1995-08-12  |  4KB  |  106 lines

  1. ;;; Commands that are useful when bound to keys.
  2.  
  3. ;;; /kb_backward_kill_line    delete from cursor to beginning of line
  4. ;;; /kb_kill_word        delete from cursor to end of punctuated word
  5. ;;; /kb_backward_kill_word    delete from cursor to start of punctuated word
  6. ;;; /kb_capitalize_word        capitialize current word
  7. ;;; /kb_downcase_word        convert current word to lowercase
  8. ;;; /kb_upcase_word        convert current word to uppercase
  9. ;;; /kb_transpose_chars        swap current character with previous character
  10. ;;; /kb_last_argument        insert last word of previous line
  11. ;;; /kb_expand_line        /eval and replace current line
  12. ;;; /kb_goto_match        move cursor to matching parenthesis or bracket
  13.  
  14. /~loaded kbfunc.tf
  15.  
  16. ;;; /dokey functions.
  17.  
  18. /def -i dokey_bspc    = /test kbdel(kbpoint() - 1)
  19. /def -i dokey_bword    = /test regmatch("[^ ]* *$$", kbhead()), \
  20.                     kbdel(kbpoint() - strlen(P0))
  21. /def -i dokey_dch    = /test kbdel(kbpoint() + 1)
  22. /def -i dokey_deol    = /test kbdel(kblen())
  23. /def -i dokey_dline    = /dokey dline
  24. /def -i dokey_down    = /test kbgoto(kbpoint() + wrapsize)
  25. /def -i dokey_dword    = /test kbdel(kbwordright())
  26. /def -i dokey_end    = /test kbgoto(kblen())
  27. /def -i dokey_home    = /test kbgoto(0)
  28. /def -i dokey_left    = /test kbgoto(kbpoint() - 1)
  29. /def -i dokey_lnext    = /dokey lnext
  30. /def -i dokey_newline    = /dokey newline
  31. /def -i dokey_recallb    = /dokey recallb
  32. /def -i dokey_recallbeg    = /dokey recallbeg
  33. /def -i dokey_recallend    = /dokey recallend
  34. /def -i dokey_recallf    = /dokey recallf
  35. /def -i dokey_redraw    = /dokey redraw
  36. /def -i dokey_right    = /test kbgoto(kbpoint() + 1)
  37. /def -i dokey_searchb    = /dokey searchb
  38. /def -i dokey_searchf    = /dokey searchf
  39. /def -i dokey_socketb    = /fg -<
  40. /def -i dokey_socketf    = /fg ->
  41. /def -i dokey_up    = /test kbgoto(kbpoint() - wrapsize)
  42. /def -i dokey_wleft    = /test kbgoto(kbwordleft())
  43. /def -i dokey_wright    = /test kbgoto(kbwordright())
  44. /def -i dokey_page    = /dokey page
  45. /def -i dokey_hpage    = /dokey hpage
  46. /def -i dokey_line    = /dokey line
  47. /def -i dokey_flush    = /dokey flush
  48. /def -i dokey_selflush    = /dokey selflush
  49.  
  50. /def -i kb_backward_kill_line = /test kbdel(0)
  51.  
  52. /def -i kb_kill_word = /test kbdel(kbwordright())
  53.  
  54. /def -i kb_backward_kill_word  = /test kbdel(kbwordleft())
  55.  
  56. /def -i kb_capitalize_word = \
  57.     /let old_insert=$[+insert]%;\
  58.     /set insert=0%;\
  59.     /test kbgoto(kbwordright()), kbgoto(kbwordleft()) %;\
  60.     /let end=$[kbwordright()]%;\
  61.     /test input(toupper(substr(kbtail(), 0, 1))) %;\
  62.     /test input(tolower(substr(kbtail(), 0, end - kbpoint()))) %;\
  63.     /set insert=%{old_insert}
  64.  
  65. /def -i kb_downcase_word = \
  66.     /let old_insert=$[+insert]%;\
  67.     /set insert=0%;\
  68.     /test input(tolower(substr(kbtail(), 0, kbwordright() - kbpoint()))) %;\
  69.     /set insert=%{old_insert}
  70.  
  71. /def -i kb_upcase_word = \
  72.     /let old_insert=$[+insert]%;\
  73.     /set insert=0%;\
  74.     /test input(toupper(substr(kbtail(), 0, kbwordright() - kbpoint()))) %;\
  75.     /set insert=%{old_insert}
  76.  
  77. /def -i kb_transpose_chars = \
  78.     /if ( kbpoint() > 0 ) \
  79.         /let old_insert=$[+insert]%;\
  80.         /set insert=0%;\
  81.         /if (kbpoint()==kblen()) /dokey_left%; /endif%;\
  82.         /dokey_left%;\
  83.         /test input(strcat(substr(kbtail(),1,1), substr(kbtail(),0,1))) %;\
  84.         /set insert=%{old_insert}%;\
  85.     /else \
  86.         /beep 1%;\
  87.     /endif
  88.  
  89. /def -i kb_last_argument = \
  90.     /input $(/last $(/recall -i - -2))
  91.  
  92. /def -i kb_expand_line = \
  93.     /eval /grab $(/recall -i 1)
  94.  
  95. /def -i kb_goto_match = \
  96.     /let match=$[kbmatch()]%; \
  97.     /test (match < 0) ? beep() : kbgoto(match)
  98.  
  99. /def -i kb_collapse_space = \
  100.     /while (substr(kbtail(), 0, 2) =~ "  ") \
  101.         /test kbdel(kbpoint() + 1)%; \
  102.     /done%; \
  103.     /while (substr(strcat(kbhead(), kbtail()), kbpoint()-1, 2) =~ "  ") \
  104.         /test kbdel(kbpoint() - 1)%; \
  105.     /done
  106.